<div class="templatemo-content-wrapper">
  <div class="templatemo-content">
    <ul class="nav nav-tabs mytabs">
      <li class="active"><a href="#">通知管理</a></li>

      <li class="nav-btn"><a href="<?=site_url('/message/add')?>" id="add"><i class="icon iconfont icon-add"></i> 发布新通知</a></li>

    </ul>
    <div class="table-responsive">
      <table class="table table-striped table-hover table-bordered">
        <thead>
          <tr>
            <th>ID</th>
            <th>标题</th>
            <th>时间</th>

            <th>操作</th>
          </tr>
        </thead>
        <tbody>
        	<?php foreach ($records as $item):?>
          <tr>
            <td><?php echo $item['id'];?></td>
            <td><?php echo $item['title'];?></td>
            <!-- <td><?php echo subtext($item['content'], 20);?></td> -->
            <td><?php echo $item['time'];?></td>

            <td style="display: none;"><?=$item['content']?></td>
            <td>
              <a href="<?=site_url('/message/edit/id/'.$item['id'])?>" class="btn btn-sm btn-default">编辑</a>
               <button type="button" class="btn btn-sm btn-default message-detail" data-toggle="popover" data-placement="left" data-trigger="focus" title="<?=$item['title']?>" data-content="" >预览</button>
               <button type="button" class="del btn btn-sm btn-danger message-detail" data-id="<?=$item['id']?>">删除</button>
            </td>
          </tr>
          <?php endforeach;?>
        </tbody>
      </table>
    </div>
    <div class="pagination" style="margin-bottom:20px;">
       <?php  echo $links; ?>
    </div>
  </div>
</div>

<script type="text/javascript">
$('[data-toggle="popover"]').popover()

$('.message-detail').each(function(){
  var text = $(this).parent().prev().text();
  $(this).attr('data-content',text)
})


$('.del').click(function(){
  var id = $(this).data('id')
  dconfirm('确定删除该通知？').ok(function(){
    drqt.post('<?=site_url()?>/message/delete', {
      id: id
    }, function(data){
      dlocation.go('<?=site_url()?>/message/index/', {toastsuccess: data.msg})
    })
  })
})
</script>
